<template>
  <div class="rateQuery">
    <div>
      <h3 style="font-weight: bold;font-size: 18px;">费率模板管理：</h3>
    </div>
    <div style="width: 100%;margin:20px auto;">
      <a-table :columns="columns" :dataSource="ratelist" :rowClassName="rowClassName" :rowKey="record => record.name" :pagination="false" size="small">
        
        <div slot="defaultValue" slot-scope="record">
          <div v-if="record.defaultValue == true">是</div>
          <div v-if="record.defaultValue == false">否</div>
        </div>
        <div slot="action" slot-scope="record">
          <div style="color:#50b4ef;cursor: pointer;"  @click="rateView(record.id,record.feeTypeName,record.name,record.code)" >查看</div>
          
        </div>
      
      </a-table>
    </div>
     <div style="text-align:center;margin: 20px 0;">
        <a-button  type="primary" style="width: 8vw;" @click="addnewrate">
          <span>新增模板</span>
          </a-button>
      </div>
    
    
  </div>
</template>
<script>
  import AHideData from "../../common/HideData";
  import api from "@/common/api";
  const columns = [
    { title: "模板类型", dataIndex: "feeTypeName" },
    { title: "模板名称", dataIndex: "name" },
    { title: "设为默认",scopedSlots: { customRender: "defaultValue" }},
    { title: "操作",scopedSlots: { customRender: "action" }}
  ];
  

  export default {
    components: {
      AHideData
    },
    data() {
      return {
        ratelist: [],
        protocolBankDTOList: [],
        columns,
        query: {},
        visible: false,
        iconLoading: false,
        issend: true,
        isChange:true,
        form: this.$form.createForm(this),
        formItemLayout: {
          labelCol: {
            xs: { span: 24 },
            sm: { span: 5 }
          },
          wrapperCol: {
            xs: { span: 24 },
            sm: { span: 20 },
            md: { span: 16 }
          }
        }
      };
    },
    mounted(){
      
    },
    activated(){
      this.getrateTemplatelist()
    },
    filters: {
      
    },
    methods: {
     rowClassName(record, index) {
      if (
        record.protocolBankDTOList == null ||
        record.protocolBankDTOList.length == 0
      ) {
        return "noExpand";
      }
    },
     getrateTemplatelist(){
       this.$axios.get('/agent/fee/group/getAgentFeeTemplateGroups').then(res => {
          console.log('res', res)
          if (res.data.code == "OK") {
              let merlist = res.data.list
              this.ratelist = []
              merlist.forEach(item => {
                if(item.code == "offline_merchant"){
                  this.ratelist.push(item)
                }
              })
              if(this.ratelist.length == 0){
                localStorage.setItem("ifTemplate",true)
              }else{
                localStorage.setItem("ifTemplate",false)
              }
          }
       })
     },
     addnewrate(){
       this.$router.push("/org/transmanage/addnewrate/offline_merchant"); 
     },
     rateView(id,feeTypeName,name,code){
       if(code == "offline_merchant"){
      //  this.$router.push({
      //   name: "商户客户费率查询",
      //   params: {
      //     id: id,
      //     feeTypeName:feeTypeName,
      //     name:name
      //   }
      // });
      this.$router.push(`/org/transmanage/merratequery/${id}`)
      }
      else if(code == "agent"){
      //  this.$router.push({
      //   name: "合作机构费率查询",
      //   params: {
      //     id: id,
      //     feeTypeName:feeTypeName,
      //     name:name
      //   }
      // });
       this.$router.push(`/org/transmanage/orgratequery/${id}`)
      }else{
          this.$message.info("当前费率不可修改")
      }
     },

    }
  };
</script>
<style lang="less" scoped>
  /deep/.noExpand {
    .ant-table-row-expand-icon {
      display: none;
    }
  }
  .rateQuery{
      overflow: scroll;
    height: 100%;
    padding: 70px;
    overflow-x: hidden;
    overflow-y: auto;
    
  }
  /*滚动条样式*/
  .rateQuery::-webkit-scrollbar {
    /*滚动条整体样式*/
    width: 4px;
    /*高宽分别对应横竖滚动条的尺寸*/
    height: 4px;
  }

  .rateQuery::-webkit-scrollbar-thumb {
    /*滚动条里面小方块*/
    border-radius: 5px;
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
    -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
    background: rgba(0, 0, 0, 0.2);
  }

  .rateQuery::-webkit-scrollbar-track {
    /*滚动条里面轨道*/
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
    -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
    border-radius: 0;
    background: rgba(0, 0, 0, 0.1);
  }
</style>